﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace DrDimsPrivateLib.MqLothub2018WithWPF.WPFUtil
{
    public static class WPFLambdaUtil
    {
        public static Size ScreenSize
        {
            get
            {
                // 0.获取.NET WPF屏幕尺寸
                var W = SystemParameters.WorkArea.Width - 2;
                var H = SystemParameters.WorkArea.Height - SystemParameters.MenuBarHeight - 2;
                return new Size(W, H);
            }
        }
        /// <summary>
        /// WPF主窗体居中函数
        /// </summary>
        /// <param name="XWindow"> 任意继承自System.Windows窗体对象 </param>
        public static void SetWPFWindowCenter(this Window XWindow)
        {
            XWindow.WindowState = WindowState.Maximized;
            XWindow.Width = ScreenSize.Width;
            XWindow.Height = ScreenSize.Height;
        }
        public static Color SolidRColor
        {
            get
            {
                var r = Convert.ToByte(random.Next(168, byte.MaxValue));
                var g = Convert.ToByte(random.Next(24, byte.MaxValue));
                var b = Convert.ToByte(random.Next(32, byte.MaxValue));
                return Color.FromArgb(0xF1, r, g, b);
            }
        }
        static internal Random random = new Random();
    }
}
